package com.sto.stoapp.thread;

import android.content.Context;
import android.util.Log;

import com.sto.stoapp.db.StoFilePreference;
import com.sto.stoapp.jpush.HttpGetFilter;
import com.sto.stoapp.util.NetUtil;

/**
 * Created by wj on 2016-11-28.
 */

public class BillFilterThread extends Thread{

    /**
     * 单号
     */
    private String billNo;
    private Context context;

    public BillFilterThread(String bill ,Context context){
        this.billNo=bill;
        this.context=context;
    }

    @Override
    public void run() {
        super.run();

        //判断是否有网络连接
        if(!NetUtil.isNetworkAvailable(context)){
            return;
        }

        String result=HttpGetFilter.getFilter(billNo);
        if(result==null){
            return;
        }

        Log.e("wj",result);
        //如果单号列表有数据，先清空
        StoFilePreference.getInstance(context).cleanBillList();
        //过滤单号保存sp
        StoFilePreference.getInstance(context).setBillList(result);
        StoFilePreference.getInstance(context).setBillTime(System.currentTimeMillis());

    }
}
